const {User}  = require('../sequelize/sequelize')

//未登录的标志
let states= 201;

fn_login =async (ctx)=>{

    let account = ctx.request.body 

    let data = await User.findAll()

    let access=data.filter((item)=>{
        return item.account==account.account && item.password==account.password
    })
    
    if (access.length>0) {
        //登录成功的标志
        states=200
        ctx.body={
            code:200,
            msg:'666'
        }
    }else{
        ctx.body={
            code:201,
            msg:'666'
        }
    }

}

fn_states=(ctx)=>{

    ctx.body=states

}


let get =[['/loginstates',fn_states]]
let post =[['/login',fn_login]]

module.exports={
    'POST':post,
    'GET':get
}